From: Anton Gladky Date: Tue, 28 Jul 2026 14:20:19 +0000 (+0200) Subject: Fix segfault writing ascii .vtu files with implicit cell type arrays X-Git-Tag: archive/raspbian/9.6.2+dfsg1-4+rpi1^2~1 X-Git-Url: https://dgit.raspbian.org/%22http://www.example.com/cgi/%22/%22http:/www.example.com/cgi/%22?a=commitdiff_plain;h=c0bf49c8ee22324b0f2daa9f57e3598e78b6e50d;p=vtk9.git Fix segfault writing ascii .vtu files with implicit cell type arrays Forwarded: not-yet NewIterator() returns nullptr for the implicit cell-type arrays used since VTK 9.6, so WriteAsciiData() dereferenced that nullptr in iter->Delete(). Merely guarding the Delete() is not enough: the templated writer already returns early on a null iterator, so the array is then written empty, and since WriteInlineData() discards the return value the writer reports success for a file which has lost all of its cells. Write such arrays through an explicit copy instead. Closes yade FTBFS. Gbp-Pq: Name fix_xmlwriter_ascii_implicit_cellarray_segfault.patch --- diff --git a/IO/XML/vtkXMLWriter.cxx b/IO/XML/vtkXMLWriter.cxx index 413f0f885..c56e26416 100644 --- a/IO/XML/vtkXMLWriter.cxx +++ b/IO/XML/vtkXMLWriter.cxx @@ -34,6 +34,7 @@ #include "vtkOutputStream.h" #include "vtkPointData.h" #include "vtkPoints.h" +#include "vtkSmartPointer.h" #include "vtkStdString.h" #include "vtkStreamingDemandDrivenPipeline.h" #include "vtkStringFormatter.h" @@ -1968,6 +1969,15 @@ int vtkXMLWriteAsciiData(ostream& os, iterT* iter, vtkIndent indent) int vtkXMLWriter::WriteAsciiData(vtkAbstractArray* a, vtkIndent indent) { vtkArrayIterator* iter = a->NewIterator(); + vtkSmartPointer copy; + if (!iter) + { + // Arrays which provide no iterator, such as the implicit arrays used since VTK 9.6 + // for uniform cell types, are written through an explicit copy. + copy.TakeReference(vtkAbstractArray::CreateArray(a->GetDataType())); + copy->DeepCopy(a); + iter = copy->NewIterator(); + } ostream& os = *(this->Stream); int ret; switch (a->GetDataType()) @@ -1978,7 +1988,10 @@ int vtkXMLWriter::WriteAsciiData(vtkAbstractArray* a, vtkIndent indent) ret = 0; break; } - iter->Delete(); + if (iter) + { + iter->Delete(); + } return ret; }